package com.traveldesign.common;
import lombok.Data;
public class Result {

    private  int code; //编码 200/400
    private  String msg; //成功、失败
    private  Long total;//总纪录数
    private  Object data;//数据

    public   static  Result fail(){
        return result(400,"失败",0L,null);
    }
    public   static  Result fail(String msg){
        return result(400,msg,0L,null);
    }

    public   static  Result suc(Object data,Long total){
        return result(200,"成功",total,data);
    }
    public   static  Result suc(Object data){
        return result(200,"成功",0L,data);
    }
    public   static  Result suc(){
        return result(200,"成功",0L,null);
    }
    public   static  Result result(int code,String msg,Long total ,Object data){
        Result res = new Result();
        res.setData(data);
        res.setMsg(msg);
        res.setCode(code);
        res.setTotal(total);
        return  res;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", total=" + total +
                ", data=" + data +
                '}';
    }



    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Long getTotal() {
        return total;
    }

    public Object getData() {
        return data;
    }
}

